﻿using OnlineOrder.Entity;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;

namespace OnlineOrder.UI.用户窗体
{
    public partial class Foods : Form
    {
        public Foods()
        {
            InitializeComponent();
        }


        private void pictureBox1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("传统中式菜肴，口感酥软，味道鲜美，深受人们喜爱。");
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("美味的淡水甲壳类海鲜，肉质鲜嫩，搭配香辣调料，口感丰富。");
        }

        private void pictureBox3_Click(object sender, EventArgs e)
        {
            MessageBox.Show("多汁的水果，甜美爽口，具有丰富的维生素和纤维，是夏季的清凉水果之一。");
        }

        private void pictureBox4_Click(object sender, EventArgs e)
        {
            MessageBox.Show("多种多样的天然食物，富含维生素和矿物质，有助于保持健康和提供营养。");
        }

        private void pictureBox5_Click(object sender, EventArgs e)
        {
            MessageBox.Show("经典的快餐食品，由肉饼、蔬菜和面包组成，口感丰富，方便快捷。");
        }

        private void pictureBox6_Click(object sender, EventArgs e)
        {
            MessageBox.Show("台湾美食，炸鸡排搭配米饭和蔬菜，口感香脆，淋上特制酱汁更美味。");
        }

        private void pictureBox7_Click(object sender, EventArgs e)
        {
            MessageBox.Show("优雅的花朵，象征纯洁和爱情，花瓣洁白如雪，香气芬芳迷人。");
        }

        private void pictureBox8_Click(object sender, EventArgs e)
        {
            MessageBox.Show("多汁的水果，酸甜可口，富含抗氧化剂，对心血管健康有益。");
        }

        private void pictureBox9_Click(object sender, EventArgs e)
        {
            MessageBox.Show("丰富多样的海洋食物，包括鱼、虾、蟹等，肉质鲜美，富含蛋白质和健康脂肪。");
        }

        private void Foods_Load(object sender, EventArgs e)
        {

        }

        
        

        private void add1_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food1.Text + "'";
            DataTable dataTable1= Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable1);
            }
            // 否则直接将查询得到的数据表赋值给 Middle.dataTable
            else
            {
                Middle.dataTable = dataTable1;
            }
            MessageBox.Show("添加成功");
        }

        private void add2_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food2.Text + "'";
            DataTable dataTable2 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable2);
            }
            else
            {
                Middle.dataTable = dataTable2;
            }
            MessageBox.Show("添加成功");
        }

        private void add3_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food3.Text + "'";
            DataTable dataTable3 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable3);
            }
            else
            {
                Middle.dataTable = dataTable3;
            }
            MessageBox.Show("添加成功");
        }

        private void add4_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food4.Text + "'";
            DataTable dataTable4 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable4);
            }
            else
            {
                Middle.dataTable = dataTable4;
            }
            MessageBox.Show("添加成功");
        }

        private void add5_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food5.Text + "'";
            DataTable dataTable5 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable5);
            }
            else
            {
                Middle.dataTable = dataTable5;
            }
            MessageBox.Show("添加成功");
        }

        private void add6_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food6.Text + "'";
            DataTable dataTable6 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable6);
            }
            else
            {
                Middle.dataTable = dataTable6;
            }
            MessageBox.Show("添加成功");
        }

        private void add7_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food7.Text + "'";
            DataTable dataTable7 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable7);
            }
            else
            {
                Middle.dataTable = dataTable7;
            }
            MessageBox.Show("添加成功");
        }

        private void add8_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food8.Text + "'";
            DataTable dataTable8 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable8);
            }
            else
            {
                Middle.dataTable = dataTable8;
            }
            MessageBox.Show("添加成功");
        }

        private void add9_Click(object sender, EventArgs e)
        {
            string sql = $"select DishName,DishPrice from Dish where DishName='" + food9.Text + "'";
            DataTable dataTable9 = Utils.SqlHelper.ExecuteDataTable(sql);
            if (Middle.dataTable.Rows.Count > 0)
            {
                Middle.dataTable.Merge(dataTable9);
            }
            else
            {
                Middle.dataTable = dataTable9;
            }
            MessageBox.Show("添加成功");
        }
    }
}
